<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Sondage extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idsondage;

    /**
     * Database var type varchar(512)
     *
     * @var string
     */
    protected $_Titre;

    /**
     * Database var type text
     *
     * @var text
     */
    protected $_Description;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_DateCreation;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_DatePublication;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_DomaineIddomaine;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_SondagepersonneIdsondagepersonne;


    /**
     * Parent relation fk_sondage_domaine1
     *
     * @var Application_Model_Domaine
     */
    protected $_Domaine;

    /**
     * Parent relation fk_sondage_sondagepersonne1
     *
     * @var Application_Model_Sondagepersonne
     */
    protected $_Sondagepersonne;


    /**
     * Dependent relation fk_participation_sondage1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Participation
     */
    protected $_Participation;

    /**
     * Dependent relation fk_Question_sondage1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_Question
     */
    protected $_Question;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idsondage'=>'Idsondage',
            'titre'=>'Titre',
            'description'=>'Description',
            'date_creation'=>'DateCreation',
            'date_publication'=>'DatePublication',
            'domaine_iddomaine'=>'DomaineIddomaine',
            'sondagepersonne_idsondagepersonne'=>'SondagepersonneIdsondagepersonne',
        ));

        $this->setParentList(array(
            'FkSondageDomaine1'=> array(
                    'property' => 'Domaine',
                    'table_name' => 'Domaine',
                ),
            'FkSondageSondagepersonne1'=> array(
                    'property' => 'Sondagepersonne',
                    'table_name' => 'Sondagepersonne',
                ),
        ));

        $this->setDependentList(array(
            'FkParticipationSondage1' => array(
                    'property' => 'Participation',
                    'table_name' => 'Participation',
                ),
            'FkQuestionSondage1' => array(
                    'property' => 'Question',
                    'table_name' => 'Question',
                ),
        ));
    }

    /**
     * Sets column idsondage
     *
     * @param int $data
     * @return Application_Model_Sondage
     */
    public function setIdsondage($data)
    {
        $this->_Idsondage = $data;
        return $this;
    }

    /**
     * Gets column idsondage
     *
     * @return int
     */
    public function getIdsondage()
    {
        return $this->_Idsondage;
    }

    /**
     * Sets column titre
     *
     * @param string $data
     * @return Application_Model_Sondage
     */
    public function setTitre($data)
    {
        $this->_Titre = $data;
        return $this;
    }

    /**
     * Gets column titre
     *
     * @return string
     */
    public function getTitre()
    {
        return $this->_Titre;
    }

    /**
     * Sets column description
     *
     * @param text $data
     * @return Application_Model_Sondage
     */
    public function setDescription($data)
    {
        $this->_Description = $data;
        return $this;
    }

    /**
     * Gets column description
     *
     * @return text
     */
    public function getDescription()
    {
        return $this->_Description;
    }

    /**
     * Sets column date_creation
     *
     * @param int $data
     * @return Application_Model_Sondage
     */
    public function setDateCreation($data)
    {
        $this->_DateCreation = $data;
        return $this;
    }

    /**
     * Gets column date_creation
     *
     * @return int
     */
    public function getDateCreation()
    {
        return $this->_DateCreation;
    }

    /**
     * Sets column date_publication
     *
     * @param string $data
     * @return Application_Model_Sondage
     */
    public function setDatePublication($data)
    {
        $this->_DatePublication = $data;
        return $this;
    }

    /**
     * Gets column date_publication
     *
     * @return string
     */
    public function getDatePublication()
    {
        return $this->_DatePublication;
    }

    /**
     * Sets column domaine_iddomaine
     *
     * @param string $data
     * @return Application_Model_Sondage
     */
    public function setDomaineIddomaine($data)
    {
        $this->_DomaineIddomaine = $data;
        return $this;
    }

    /**
     * Gets column domaine_iddomaine
     *
     * @return string
     */
    public function getDomaineIddomaine()
    {
        return $this->_DomaineIddomaine;
    }

    /**
     * Sets column sondagepersonne_idsondagepersonne
     *
     * @param int $data
     * @return Application_Model_Sondage
     */
    public function setSondagepersonneIdsondagepersonne($data)
    {
        $this->_SondagepersonneIdsondagepersonne = $data;
        return $this;
    }

    /**
     * Gets column sondagepersonne_idsondagepersonne
     *
     * @return int
     */
    public function getSondagepersonneIdsondagepersonne()
    {
        return $this->_SondagepersonneIdsondagepersonne;
    }

    /**
     * Sets parent relation DomaineIddomaine
     *
     * @param Application_Model_Domaine $data
     * @return Application_Model_Sondage
     */
    public function setDomaine(Application_Model_Domaine $data)
    {
        $this->_Domaine = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['iddomaine'];
        }

        $this->setDomaineIddomaine($primary_key);

        return $this;
    }

    /**
     * Gets parent DomaineIddomaine
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Domaine
     */
    public function getDomaine($load = true)
    {
        if ($this->_Domaine === null && $load) {
            $this->getMapper()->loadRelated('FkSondageDomaine1', $this);
        }

        return $this->_Domaine;
    }

    /**
     * Sets parent relation SondagepersonneIdsondagepersonne
     *
     * @param Application_Model_Sondagepersonne $data
     * @return Application_Model_Sondage
     */
    public function setSondagepersonne(Application_Model_Sondagepersonne $data)
    {
        $this->_Sondagepersonne = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idsondagepersonne'];
        }

        $this->setSondagepersonneIdsondagepersonne($primary_key);

        return $this;
    }

    /**
     * Gets parent SondagepersonneIdsondagepersonne
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Sondagepersonne
     */
    public function getSondagepersonne($load = true)
    {
        if ($this->_Sondagepersonne === null && $load) {
            $this->getMapper()->loadRelated('FkSondageSondagepersonne1', $this);
        }

        return $this->_Sondagepersonne;
    }

    /**
     * Sets dependent relations fk_participation_sondage1
     *
     * @param array $data An array of Application_Model_Participation
     * @return Application_Model_Sondage
     */
    public function setParticipation(array $data)
    {
        $this->_Participation = array();

        foreach ($data as $object) {
            $this->addParticipation($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_participation_sondage1
     *
     * @param Application_Model_Participation $data
     * @return Application_Model_Sondage
     */
    public function addParticipation(Application_Model_Participation $data)
    {
        $this->_Participation[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_participation_sondage1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Participation
     */
    public function getParticipation($load = true)
    {
        if ($this->_Participation === null && $load) {
            $this->getMapper()->loadRelated('FkParticipationSondage1', $this);
        }

        return $this->_Participation;
    }

    /**
     * Sets dependent relations fk_Question_sondage1
     *
     * @param array $data An array of Application_Model_Question
     * @return Application_Model_Sondage
     */
    public function setQuestion(array $data)
    {
        $this->_Question = array();

        foreach ($data as $object) {
            $this->addQuestion($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_Question_sondage1
     *
     * @param Application_Model_Question $data
     * @return Application_Model_Sondage
     */
    public function addQuestion(Application_Model_Question $data)
    {
        $this->_Question[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_Question_sondage1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_Question
     */
    public function getQuestion($load = true)
    {
        if ($this->_Question === null && $load) {
            $this->getMapper()->loadRelated('FkQuestionSondage1', $this);
        }

        return $this->_Question;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Sondage
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Sondage());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Sondage::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdsondage() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idsondage = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdsondage()));
    }
}
